package BookManagement.dao;

import BookManagement.domain.Spend;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

@Repository
public interface SpendDao {

    @Insert("insert into spend values(#{userName},#{type},#{time},#{changes},#{balance})")
    public int newspend(Spend spend);

    @Select("<script>"+"select * from spend where username=#{username} order by time desc "+
            "<if test='start!=null and size!=null'>"+"limit #{start},#{size}"+"</if>"
            +"</script>"
    )
    public List<Spend> findUserSpend(HashMap<String,Object> map);

    @Select("select count(*) from spend where username=#{username}")
    public int findSpendCount(String username);
}
